﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TraineeManagement.Models.BusinessObject
{
    public class SessionBO : GenericBusiness<Session>
    {
        private TraineeBO TBO = new TraineeBO();

        public List<Session> GetAllSessionsOfTrainee(int traineeID)
        {
            Trainee trainee = TBO.GetTraineeById(traineeID);
            return trainee.Sessions.ToList();
        }

        public Session GetSessionById(int sessionID)
        {
            try
            {
                return base.GetSingle(s => s.SessionID == sessionID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void AddSession(Session newSession)
        {
            try
            {
                base.Insert(newSession);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public void UpdateSession(Session modifiedSession)
        {
            try
            {
                base.Update(modifiedSession);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public void DeleteSession(Session session)
        {
            try
            {
                base.Delete(session);
            }
            catch (Exception)
            {

                throw;
            }
        }

    }
}